import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

///路由跳转,入栈

goTo(BuildContext context, Widget page) {
  if (Theme.of(context).platform == TargetPlatform.android) {
    //安卓是使用默认动画,从底部弹出
    Navigator.push(
      context,
      MaterialPageRoute(builder: (context) => page),
    );
  } else {
    //ios使用的是左右滑动进入退出,可根据需求使用
    Navigator.push(
      context,
      CupertinoPageRoute(builder: (context) => page),
    );
  }
}

///路由跳转,替换
goToReplace(BuildContext context, Widget page) {
  if (Theme.of(context).platform == TargetPlatform.android) {
    Navigator.pushReplacement(
      context,
      MaterialPageRoute(builder: (context) => page),
    );
  } else {
    Navigator.pushReplacement(
      context,
      CupertinoPageRoute(builder: (context) => page),
    );
  }
}
